<template>
  <div class="cantainer">
    <el-row>
      <el-col :span="6"><searchtime/></el-col>
      <el-col :span="6"><searchregister/></el-col>
      <el-col :span="6"><search/></el-col>
      <el-col :span="6"><create/></el-col>
    </el-row>
    <el-table
      border
      style="width: 100%;"
      :data="userList.slice((currentPage-1)*pagesize,currentPage*pagesize)"
    >
      <el-table-column type="index" align="center"></el-table-column>
      <el-table-column label="ID" prop="id" min-width="100" align="center"></el-table-column>
      <el-table-column label="用户名" prop="username" min-width="100" align="center"></el-table-column>
      <el-table-column label="手机号" prop="phone" min-width="200" align="center"></el-table-column>
      <el-table-column label="邮箱" prop="email" min-width="200" align="center"></el-table-column>
      <el-table-column label="注册时间" prop="registerdate" min-width="200" align="center"></el-table-column>
      <el-table-column label="最近登录" prop="latest" min-width="200" align="center"></el-table-column>
      <el-table-column label="操作" prop="handle" min-width="200" align="center">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      style="float:right;margin-top:5px;"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5,10,15]"
      :page-size="pagesize"
      layout="prev, pager,next"
      :total="userList.length"
    ></el-pagination>
  </div>
</template>

<script>
import { Create, Search, Searchregister, Searchtime } from "./components"

export default {
  name: 'user',
  components:{
    Create,
    Search,
    Searchregister,
    Searchtime
  },
  data() {
    return {
      currentPage: 1,
      pagesize: 5,
      userList: [
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        },
        {
          id: "1",
          username: "张三",
          phone: "13434333343",
          email: "1876213@qq.com",
          registerdate: "2019-2-23 \n 中国境内",
          latest: "2019-2-24"
        }
      ]
    };
  },
  methods: {
    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function(size) {
      this.pagesize = size
      console.log(this.pagesize) //每页下拉显示数据
    },
    handleCurrentChange: function(currentPage) {
      this.currentPage = currentPage
      console.log(this.currentPage) //点击第几页
    }
  }
};
</script>


<style>
.el-table .cell {
  white-space: pre-line；
}
.cantainer{
  padding:10px 10px;
}
</style>


